<template>
	<z-paging ref="paging" v-model="list" @query="getList" loading-more-default-text="我也是有底线的哦">
		<view class="mainBg h100">
			<navbar title="我的退款" />
			<view class="tabs">
				<view class="tab" :class="status == `success` ? `active` : ``" @click="changeStatus(`success`)">
					可申请退款订单
				</view>
				<view class="tab" :class="status == `refund` ? `active` : ``" @click="changeStatus(`refund`)">
					已完成退款订单
				</view>
			</view>
			<view class="list">
				<view class="col" v-for="item,index in list" :key="item.id">
					<item :item="item" @handleOpen="handleOpen" :scene="scene" />
				</view>
			</view>
		</view>
		<refund ref="refundRef" :orderId="orderId" />
	</z-paging>
</template>

<script>
	import item from "./item.vue"
	import refund from "./components/refund.vue"
	export default {
		components: {
			item,
			refund
		},
		data() {
			return {
				list: [],
				pageNo:1,
				pageSize:10,
				status:'success',
				scene:'refund',
				orderId:'',
			}
		},
		methods: {
			getList(pageNo, pageSize) {
				this.$get(`/order/orderList`, {
						pageNum: this.pageNo,
						pageSize:this.pageSize,
						status:this.status,
					}).then(res => {
						//请勿在网络请求回调中给dataList赋值！！只需要调用complete就可以了
						this.$refs.paging.complete(res.data.rows);
					})
			},
			changeStatus(status){
				this.status = status
				this.$refs.paging.reload() 
			},
			handleOpen(orderId) {
				this.orderId = orderId
				this.$refs.refundRef.open()
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #35CBAD;
	}

	.tabs {
		display: flex;
		background-color: #fff;

		.tab {
			flex: 1;
			font-size: 28rpx;
			text-align: center;
			line-height: 100rpx;
			position: relative;
		}

		.active {
			font-weight: bold;
			color: $assist-color2;

			&:before {
				content: '';
				width: 80rpx;
				height: 6rpx;
				position: absolute;
				left: 50%;
				bottom: 0%;
				transform: translateX(-50%);
				background-color: $assist-color2;
			}
		}
	}

	.list {
		padding: 10rpx 0;

		.col {
			padding: 10rpx 0;
		}
	}
</style>